<template>
  <div>
    <!-- 面包屑导航区 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>作者管理</el-breadcrumb-item>
      <el-breadcrumb-item>作者事务</el-breadcrumb-item>
      <el-breadcrumb-item>出书邀约</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card>
      <el-table v-loading="loading" :data="authorList" style="width: 100%">
        <el-table-column type="index"> </el-table-column>
        <el-table-column prop="authorName" label="作者名称"> </el-table-column>
        <el-table-column prop="roleName" label="作者类别"> </el-table-column>
        <el-table-column prop="authorMobile" label="作者电话">
        </el-table-column>
        <el-table-column prop="address" label="操作">
          <el-button type="text" @click="dialogVisible = true"
            >出书邀约</el-button
          >
        </el-table-column>
      </el-table>
    </el-card>

    <el-dialog
      title="出书邀约"
      :visible.sync="dialogVisible"
      width="40%"
      @close="handleClose"
    >
      <el-form
        :model="sendInfo"
        :rules="sendRule"
        ref="sendRef"
        label-position="top"
        style="padding: 0 50px"
        label-width="80px"
      >
        <el-form-item label="书名" prop="bookName">
          <el-input v-model="sendInfo.bookName"></el-input> </el-form-item
      ></el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="sendBook">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false,
      authorList: [],
      dialogVisible: false,
      classList: [],
      sendInfo: { bookName: "" },
      sendRule: {
        bookName: [{ required: true, message: "请输入书名", trigger: "blur" }],
      },
    };
  },
  methods: {
    //获取客户信息
    async getAuthorList() {
      this.loading = true;
      const { data: res } = await this.$http.get("/authorUser");
      if (res.status !== 200) return this.$message.error(res.msg);
      this.authorList = res.authorList;
      this.loading = false;
    },

    async sendBook() {
      if (this.time === "") return this.$message.error("请选择时间");
      const confirmResult = await this.$confirm("是否确认发送邀请？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).catch((err) => err);
      if (confirmResult != "confirm") return this.$message.info("已取消");
      this.$message.success("已发送!");
      this.dialogVisible = false;
    },
    handleClose() {
      this.$refs.sendRef.resetFields();
    },
  },
  created() {
    this.getAuthorList();
  },
};
</script>

<style scoped>
.el-card {
  height: 600px;
}
.block {
  padding: 0 50px;
}
.el-date-picker {
  margin-top: 20px !important;
}
</style>
